package xyz.thoughtset.viewer.modules.step.entity;

import lombok.Getter;

@Getter
public enum BlockTypeEnum {
    // 任务块
    TASK("task", TaskBody.class),
    // 分支块
    CHOOSE("choose", ChooseBody.class),
    // 循环块
    LOOP("loop", LoopBody.class),
    // 循环块
    ITERATOR("iterator", IteratorBody.class),
    // 并行块
//    PARALLEL("parallel", ParallelBody.class),
    TOOLS("tools", ToolsBody.class),
    // MCP
    MCP("mcp", MCPBody.class),
    // FunctionCall
    FUNCTION_CALL("FunctionCall", FunctionCallBody.class),
    // ExecAI
    EXECAI("ExecAI", ExecAIBody.class),
    VALUE("value", ValueBody.class),
    // 单体块
    DEFAULT("default", SingleBody.class),
    SINGLE("single", SingleBody.class),
    TRANSPOSE("transpose", TransposeBody.class);

    private final String type;
    private final Class typeClass;

    BlockTypeEnum(String type,Class typeClass) {
        this.type = type;
        this.typeClass = typeClass;
    }


    public static BlockTypeEnum fromType(String type) {
        for (BlockTypeEnum blockType : BlockTypeEnum.values()) {
            if (blockType.getType().equalsIgnoreCase(type)) {
                return blockType;
            }
        }
        return DEFAULT;
//        throw new IllegalArgumentException("Unknown block type: " + type);
    }

    public static BlockTypeEnum fromClass(Class typeArg) {
        for (BlockTypeEnum blockType : BlockTypeEnum.values()) {
            if (blockType.getTypeClass().equals(typeArg)) {
                return blockType;
            }
        }
        throw new IllegalArgumentException("Unknown block type: " + typeArg.getName());
    }
}
